package com.spider.demo;

public class MovieOperator {
    private Movie[] movies;

    public MovieOperator(Movie[] movies) {
        this.movies = movies;
    }

    public void printAll() {
        System.out.println("全部电影如下：");
        System.out.println("编号\t" + "电影名称\t" + "价格\t" + "主演");
        for (int i = 0; i < movies.length; i++) {
            Movie movie = movies[i];
            System.out.println(movie.getId() + "\t" + movie.getName() + "\t" + movie.getPrice() + "\t" + movie.getActor());
        }
    }

    public void searchMovieById() {
        System.out.println("请输入要查询的编号：");
        String id = new java.util.Scanner(System.in).next();
        for (int i = 0; i < movies.length; i++) {
            Movie movie = movies[i];
            if (id.equals(movie.getId())) {
                System.out.println(movie.getId() + "\t" + movie.getName() + "\t" + movie.getPrice() + "\t" + movie.getActor());
                return;
            }
        }
    }
}
